home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / sysdeps / standalone / i960 / start.S < prev   
Encoding:
Text File  |  1994-08-28  |  3.9 KB  |  138 lines

  1. /* Copyright (C) 1994 Free Software Foundation, Inc.
  2.    Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
  3.      On-Line Applications Research Corporation.
  4.  
  5. This file is part of the GNU C Library.
  6.  
  7. The GNU C Library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Library General Public License as
  9. published by the Free Software Foundation; either version 2 of the
  10. License, or (at your option) any later version.
  11.  
  12. The GNU C Library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. Library General Public License for more details.
  16.  
  17. You should have received a copy of the GNU Library General Public
  18. License along with the GNU C Library; see the file COPYING.LIB.  If
  19. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  20. Cambridge, MA 02139, USA.  */
  21.  
  22. /*  entry.s
  23.  *
  24.  *  This file contains the entry point for the application.
  25.  *  The name of this entry point is compiler dependent.
  26.  *  It jumps to the BSP which is responsible for performing
  27.  *  all initialization.
  28.  *
  29.  */
  30.  
  31.          .text
  32.          .globl  start                  # GNU960 default entry point
  33.  
  34. start:
  35.         mov     3, r12
  36.         modpc   r12, r12, r12         # enable tracing/trace faults
  37.         mov     g5, g5                # NOP
  38.         mov     0, g14                # initialize constant for C
  39.  
  40.         /*
  41.          * zero out uninitialized data area
  42.          */
  43. zerobss:
  44.         lda     _end, r4        /* find end of .bss */
  45.         lda     _bss_start, r5  /* find beginning of .bss */
  46.         ldconst 0, r6
  47.  
  48. loop:   st      r6, (r5)        /* to zero out uninitialized */
  49.         addo    4, r5, r5       /* data area                 */
  50.         cmpobl  r5, r4, loop    /* loop until _end reached   */
  51.  
  52.  
  53.         lda     heap_memory, r12      /* tell C lib where heap is */
  54.         st      r12,___C_heap_start
  55.         lda     heap_size, r12        /* tell C lib how big heap is */
  56.         st      r12,___C_heap_size
  57.         lda     stack_memory,r12      /* set up stack pointer: */
  58.         mov     r12, sp
  59.         mov     0, g14           /* initialize constant for C */
  60.  
  61.         call    init_frames
  62.         ret                      /* return to monitor */
  63.  
  64. init_frames:
  65.         ldconst 0x3b001000, g0
  66.         ldconst 0x00009107, g1
  67.         modac   g1, g0, g0       /* set AC controls */
  68.  
  69.         /*
  70.          * Call application mainline.
  71.          *      Someday, real values of argc and argv will be set up.
  72.          *      For now, they are set to 0.
  73.          */
  74.  
  75.         callx   __Board_Initialize    /* Initialize the board */
  76.  
  77.         ldconst 0,g0
  78.         ldconst 0,g1
  79.         ldconst 0,g2
  80.         callx   ___libc_init          /* initialize the library and */
  81.                                       /*   call main */
  82.         /*
  83.          * if we return from main, we have "fallen" off the end
  84.          * of the program, therefore status is 0
  85.          * so move 0 to g0 (exit parameter)
  86.          */
  87.  
  88.         mov     0, g0
  89.         callx   __exit
  90.         ret
  91.  
  92.  
  93. /*
  94.  *  Data Declarations.  Start with a macro which helps declare space.
  95.  */
  96.  
  97. #define DECLARE_SPACE(_name,_space,_align) \
  98.           .globl   _name ; \
  99.           .align   _align ; \
  100. .comm     _name##,_space
  101.  
  102. #define DECLARE_LABEL(_name) \
  103.           .globl   _name ; \
  104. _name##:  
  105.  
  106. #define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2)
  107. #define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2)
  108. #define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1)
  109.  
  110. /*
  111.  *  Require environment stuff
  112.  */
  113.  
  114. DECLARE_LABEL(_environ)
  115. DECLARE_PTR(environ)
  116.  
  117. DECLARE_LABEL(_errno)
  118. DECLARE_U32(errno)
  119.  
  120. /*
  121.  *  Stack Size and Space
  122.  */
  123.  
  124.         .set stack_size, 0x20000
  125.  
  126. DECLARE_SPACE(stack_memory,stack_size,4)
  127. DECLARE_LABEL(stack_end)
  128.  
  129. /*
  130.  *  Heap Size and Space
  131.  */
  132.  
  133.         .set heap_size, 0x20000
  134.  
  135. DECLARE_SPACE(heap_memory,heap_size,4)
  136. DECLARE_LABEL(heap_end)
  137.  
  138.